﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Polla.ServiceReference1;


namespace Polla
{
    public partial class ListaEvento : PhoneApplicationPage
    {
        public ListaEvento()
        {
            InitializeComponent();
        }


        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

            Service1Client client = new Service1Client();
            client.ListaEventosCompleted += new EventHandler<ListaEventosCompletedEventArgs>(Lista_eventosComplped2);
            client.ListaEventosAsync(client);
     

            
       }


        void Lista_eventosComplped2(object sender, ListaEventosCompletedEventArgs e)
        {
            Service1Client client = e.UserState as Service1Client;
            client.ListaEventosCompleted -= Lista_eventosComplped2;

            if (e.Error != null)
            {
                return;
            }

            List<Evento> lista = new List<Evento>();

            int numero = e.Result.Count();

            for (int i = 0; 1<=numero; i++)
            {
                Evento objEvento = new Evento();
                objEvento.Id = e.Result[i].Id;
                objEvento.Fecha = e.Result[i].Fecha;
                objEvento.Apuesta = e.Result[i].Apuesta;
                objEvento.Disciplina = e.Result[i].Disciplina;
                objEvento.Local = e.Result[i].Local;
                objEvento.Visitante = e.Result[i].Visitante;
                objEvento.Pozo = e.Result[i].Pozo;
                
                
                lista.Add(objEvento);


            }
            lstEvento.ItemsSource = lista;
  
        }





    }
}